<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTTP 2.0 技术解析 | 现代网络性能革命</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #0061ff 0%, #60efff 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-box {
            position: relative;
        }
        .highlight-box::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 4px;
            background: linear-gradient(to bottom, #0061ff, #60efff);
            border-radius: 2px;
        }
        .dropcap::first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.9;
            margin: 0.1em 0.15em 0 0;
            color: #0061ff;
            font-family: 'Noto Serif SC', serif;
            font-weight: 700;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-2/3 md:pr-10">
                    <h1 class="serif text-4xl md:text-5xl lg:text-6xl font-bold mb-6 leading-tight">
                        HTTP 2.0: 现代网络性能革命
                    </h1>
                    <p class="text-xl md:text-2xl opacity-90 mb-8">
                        从单车道到高速公路的进化，探索网络传输效率的质的飞跃
                    </p>
                    <div class="flex items-center space-x-4">
                        <div class="bg-white bg-opacity-20 px-4 py-2 rounded-full flex items-center">
                            <i class="fas fa-bolt mr-2"></i>
                            <span>多路复用技术</span>
                        </div>
                        <div class="bg-white bg-opacity-20 px-4 py-2 rounded-full flex items-center">
                            <i class="fas fa-compress-alt mr-2"></i>
                            <span>头部压缩</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/3 mt-10 md:mt-0">
                    <div class="bg-white bg-opacity-10 p-6 rounded-xl backdrop-filter backdrop-blur-sm">
                        <div class="text-center">
                            <i class="fas fa-exchange-alt text-4xl mb-4 opacity-80"></i>
                            <h3 class="text-xl font-bold mb-2">协议进化对比</h3>
                            <p class="opacity-80">HTTP 1.0与2.0核心差异可视化</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Content Section -->
    <section class="py-16 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl">
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card-hover">
                <div class="p-8 md:p-10">
                    <div class="dropcap">
                        <p>HTTP 2.0 的设计充分考虑了现代网页的复杂性和性能需求，通过多路复用、头部压缩和更好的连接管理，大幅提升了网络传输效率，解决了 HTTP 1.0 中的许多瓶颈问题。通俗来说，HTTP 1.0 像是单车道的交通，每辆车都得等前面的车开走才能上路；而 HTTP 2.0 则像是多车道高速公路，所有的车可以同时行驶，从而大大加快了整体速度。</p>
                    </div>
                </div>
            </div>

            <!-- Comparison Chart -->
            <div class="mb-16">
                <h2 class="serif text-3xl font-bold mb-8 text-center">HTTP 1.0 vs 2.0 关键特性对比</h2>
                <div class="mermaid">
                    graph TD
                        A[HTTP 1.0] -->|单连接| B[队头阻塞问题]
                        A -->|文本协议| C[解析效率低]
                        A -->|完整头部| D[带宽浪费]
                        A -->|被动响应| E[延迟高]
                        
                        F[HTTP 2.0] -->|多路复用| G[并行传输]
                        F -->|二进制协议| H[高效解析]
                        F -->|头部压缩| I[节省带宽]
                        F -->|服务器推送| J[主动推送资源]
                        F -->|持久连接| K[减少开销]
                </div>
            </div>

            <!-- Features Section -->
            <div class="space-y-12">
                <!-- Multiplexing -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-8 md:p-10">
                        <div class="flex items-center mb-6">
                            <div class="bg-blue-100 p-3 rounded-lg mr-4">
                                <i class="fas fa-code-branch text-blue-600 text-xl"></i>
                            </div>
                            <h2 class="serif text-2xl font-bold">多路复用（Multiplexing）</h2>
                        </div>
                        <div class="grid md:grid-cols-2 gap-8">
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-700">HTTP 1.0</h3>
                                <p class="text-gray-600">每次请求都需要建立一个新的 TCP 连接，导致了"队头阻塞"问题，即一个请求的响应阻塞了其他请求的处理。</p>
                            </div>
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-blue-600">HTTP 2.0</h3>
                                <p>引入了多路复用技术，在一个 TCP 连接中同时处理多个请求和响应，从而大幅减少了延迟，避免了队头阻塞的问题。</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Header Compression -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-8 md:p-10">
                        <div class="flex items-center mb-6">
                            <div class="bg-purple-100 p-3 rounded-lg mr-4">
                                <i class="fas fa-compress-alt text-purple-600 text-xl"></i>
                            </div>
                            <h2 class="serif text-2xl font-bold">头部压缩（Header Compression）</h2>
                        </div>
                        <div class="grid md:grid-cols-2 gap-8">
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-700">HTTP 1.0</h3>
                                <p class="text-gray-600">每次请求都会重复发送完整的请求头部，增加了带宽消耗。</p>
                            </div>
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-purple-600">HTTP 2.0</h3>
                                <p>使用 HPACK 算法对请求和响应头部进行压缩，从而减少了传输的数据量，提高了传输效率。</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Server Push -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-8 md:p-10">
                        <div class="flex items-center mb-6">
                            <div class="bg-green-100 p-3 rounded-lg mr-4">
                                <i class="fas fa-paper-plane text-green-600 text-xl"></i>
                            </div>
                            <h2 class="serif text-2xl font-bold">服务器推送（Server Push）</h2>
                        </div>
                        <div class="grid md:grid-cols-2 gap-8">
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-700">HTTP 1.0</h3>
                                <p class="text-gray-600">客户端必须明确发起请求，服务器才能响应。</p>
                            </div>
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-green-600">HTTP 2.0</h3>
                                <p>服务器可以主动向客户端推送资源，即使客户端没有明确请求。这种机制可以减少客户端等待资源加载的时间，提升页面加载速度。</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Connection Persistence -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-8 md:p-10">
                        <div class="flex items-center mb-6">
                            <div class="bg-yellow-100 p-3 rounded-lg mr-4">
                                <i class="fas fa-link text-yellow-600 text-xl"></i>
                            </div>
                            <h2 class="serif text-2xl font-bold">连接的持久性</h2>
                        </div>
                        <div class="grid md:grid-cols-2 gap-8">
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-700">HTTP 1.0</h3>
                                <p class="text-gray-600">默认每次请求都会建立一个新的 TCP 连接，但可以通过 `Connection: keep-alive` 头部来维持连接。</p>
                            </div>
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-yellow-600">HTTP 2.0</h3>
                                <p>所有请求和响应都在一个长连接上完成，进一步减少了建立和断开连接的开销。</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Binary Protocol -->
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-8 md:p-10">
                        <div class="flex items-center mb-6">
                            <div class="bg-red-100 p-3 rounded-lg mr-4">
                                <i class="fas fa-file-code text-red-600 text-xl"></i>
                            </div>
                            <h2 class="serif text-2xl font-bold">二进制协议</h2>
                        </div>
                        <div class="grid md:grid-cols-2 gap-8">
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-gray-700">HTTP 1.0</h3>
                                <p class="text-gray-600">使用的是纯文本格式，解析相对复杂，效率较低。</p>
                            </div>
                            <div class="highlight-box pl-6">
                                <h3 class="text-xl font-semibold mb-4 text-red-600">HTTP 2.0</h3>
                                <p>采用二进制格式进行数据帧传输，更加高效且易于解析，减少了误解的可能性。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Visual Comparison -->
    <section class="py-16 bg-gray-100 px-4 md:px-0">
        <div class="container mx-auto max-w-4xl">
            <h2 class="serif text-3xl font-bold mb-12 text-center">HTTP 协议传输方式对比</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-8 rounded-xl shadow-md">
                    <div class="flex items-center mb-6">
                        <div class="bg-gray-600 text-white p-2 rounded-full w-10 h-10 flex items-center justify-center mr-4">
                            <span>1.0</span>
                        </div>
                        <h3 class="text-xl font-bold">HTTP 1.0 - 单车道</h3>
                    </div>
                    <div class="space-y-4">
                        <div class="flex items-center bg-gray-100 p-3 rounded-lg">
                            <div class="w-8 h-8 bg-blue-500 rounded-full mr-3 flex-shrink-0"></div>
                            <div class="w-full h-4 bg-gray-300 rounded-full"></div>
                        </div>
                        <div class="flex items-center bg-gray-100 p-3 rounded-lg">
                            <div class="w-8 h-8 bg-blue-500 rounded-full mr-3 flex-shrink-0"></div>
                            <div class="w-3/4 h-4 bg-gray-300 rounded-full"></div>
                        </div>
                        <div class="flex items-center bg-gray-100 p-3 rounded-lg">
                            <div class="w-8 h-8 bg-blue-500 rounded-full mr-3 flex-shrink-0"></div>
                            <div class="w-2/3 h-4 bg-gray-300 rounded-full"></div>
                        </div>
                    </div>
                    <p class="mt-6 text-gray-600">请求必须按顺序处理，前一个请求完成后才能开始下一个</p>
                </div>
                <div class="bg-white p-8 rounded-xl shadow-md">
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-600 text-white p-2 rounded-full w-10 h-10 flex items-center justify-center mr-4">
                            <span>2.0</span>
                        </div>
                        <h3 class="text-xl font-bold">HTTP 2.0 - 多车道</h3>
                    </div>
                    <div class="grid grid-cols-3 gap-3">
                        <div class="bg-blue-100 p-3 rounded-lg h-24 flex items-end">
                            <div class="w-full h-3/4 bg-blue-500 rounded-t-lg"></div>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-lg h-32 flex items-end">
                            <div class="w-full h-full bg-blue-500 rounded-t-lg"></div>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-lg h-20 flex items-end">
                            <div class="w-full h-1/2 bg-blue-500 rounded-t-lg"></div>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-lg h-28 flex items-end">
                            <div class="w-full h-5/6 bg-blue-500 rounded-t-lg"></div>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-lg h-16 flex items-end">
                            <div class="w-full h-1/3 bg-blue-500 rounded-t-lg"></div>
                        </div>
                        <div class="bg-blue-100 p-3 rounded-lg h-24 flex items-end">
                            <div class="w-full h-3/4 bg-blue-500 rounded-t-lg"></div>
                        </div>
                    </div>
                    <p class="mt-6 text-gray-600">多个请求可以并行处理，充分利用连接带宽</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-4xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术的无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors duration-300 flex items-center">
                        <i class="fas fa-globe mr-2"></i>
                        <span>www.yuque.com/jtostring</span>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>